﻿using System;
using System.Collections.ObjectModel;
using System.Xml.Serialization;

namespace EpiNEXT.Services.Validation.Actions
{
    //[Serializable()]
    public sealed class Action_Invalidate : ActionBase
    {
        [XmlArray("Messages")]
        [XmlArrayItem("Messages", typeof(FieldTextPropertyTranslation))]
        public ObservableCollection<FieldTextPropertyTranslation> Messages { get; set; }

        public string GetMessage()
        {
            string currentCulture = System.Globalization.CultureInfo.CurrentUICulture.ToString();

            foreach (FieldTextPropertyTranslation message in Messages)
            {
                if (message.Culture.Equals(currentCulture))
                {
                    return message.Text;
                }
            }

            return "Invalid data detected";
        }
    }
}
